AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones del programador de Windows
  • Overview
  • ScheduledTask structure
  • Example
  • Example for adding a task
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
The ScheduledTask structure is used to define the characteristics of a scheduled task. The variables of this structure are reinitialized by SchedulerReset.
Note: When creating a new task, the structure PlannedTask is used, as well as the TriggerScheduledTask structure.
ScheduledTask structure
The different variables of ScheduledTask structure are as follows:
ScheduledTask.ApplicationCharacter string.
Name and path of program to run.
ScheduledTask.StopOnIdleEndBoolean.
True if the task must be stopped as soon as the system resumes an activity.
This variable is set to False by default.
ScheduledTask.StopOnBatteriesBoolean.
True if the task must be stopped when the computer switches to battery power.
This variable is set to True by default.
ScheduledTask.ErrorCodeInteger.
Last error code returned by the task (0 if the task was successfully completed or if the program has never been started).
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.CommentCharacter string.
Comment associated with the task. This comment will be visible in the task properties. This comment can be multilingual.
ScheduledTask.IdleWaitTimeoutInteger in minutes.
Timeout during which the system will wait for an idle time before performing the task.
If ScheduledTask.IdleTimeout is not set to 0, this variable is used to specify the amount of time required before the system cancels the task execution.
This variable is set to 60 minutes by default.
ScheduledTask.IdleTimeoutInteger in minutes.
Amount of system idle time required before performing the task. The task will be performed only if the system is inactive.
Example: An antivirus scan is performed every day at 1:00 PM if the system is inactive since 30 minutes.
This variable is set to 0 (immediate timeout) by default.
ScheduledTask.LastRunDateDateTime.
Date of last task execution.
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.MaxRunTimeDuration.
Maximum task duration. Amount of time required before the system ends the task.
If this variable is set to 0, the task will be run as long as necessary.
This variable is set to 72 hours by default.
Note: This variable can correspond to:
  • an integer corresponding to the number of hundredths of a second,
  • a Duration variable,
  • direct indication of duration (e.g. 1 h).
ScheduledTask.SystemOnBoolean.
  • True if the computer must be woken up to perform this task (the system must not be in sleep mode),
  • False otherwise.
This variable is set to False by default.
ScheduledTask.RunIfLoggedOnBoolean.
  • True if the task must be performed only when an interactive session (with user identification) is started on the computer of user identified by ScheduledTask.User,
  • False otherwise.
This feature allows you not to specify the user password (however, the username must be specified).
The default value for this variable is False the task will run even if the session is closed.
Note: This variable only works with Windows XP (does not work with 2000).
ScheduledTask.CommandLineCharacter string.
Parameters to pass in command line to the application that will be run.
ScheduledTask.PasswordCharacter string.
User password. This user was specified in ScheduledTask.User. Used to perform a scheduled task according to a user account.
If this password is modified, this modification will also apply to all the tasks linked to this user.
ScheduledTask.TriggerCountInteger.
Number of task triggers (events that will start the task).
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.DontRunIfOnBatteriesBoolean.
True if the task must be stopped when the computer switches to battery power.
This variable is set to True by default.
ScheduledTask.NextRunTimeDateTime.
Date of next scheduled task execution.
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.WorkingDirectoryCharacter string.
Working directory of the application to run (empty string if the working directory corresponds to the scheduler directory (MSTASK.EXE)).
Caution: If this directory is not filled in, it corresponds to the PlannedTask.Application directory..
ScheduledTask.DeleteWhenDoneBoolean.
True if the task must be deleted automatically when there is no more possible conditions for running it (the end date of each occurrence has been reached for example).
This variable is set to False by default.
ScheduledTask.UserCharacter string.
Name of user whose account is used to perform the task.
Note: if you are using a domain, you need to specify the domain.
Example

Example for adding a task

SchedulerReset()
// Création de la tache planifiée
ScheduledTask.Application = "MonExécutable.exe"
ScheduledTask.CommandLine = ReqToutSurUneBackup.Nom
ScheduledTask.SystemOn = True
ScheduledTask.Comment = "Programme WINDEV"

// Création des horaires de la tâche planifiée
// nTypeSauvegarde est un sélecteur proposant une sauvegarde 
// unique, hebdomadaire, mensuelle...

TriggerScheduledTask.Type = nTypeSauvegarde

// Date d'exécution de la sauvegarde unique
IF nTypeSauvegarde = schedDaily THEN
	IF SAI_DateUnique <> "" THEN
		IF SAI_HoraireUnique <> "" THEN
			TriggerScheduledTask.Date = SAI_DateUnique 
			TriggerScheduledTask.Time = SAI_HoraireUnique
		ELSE
			Info("Vous devez saisir une heure valide de sauvegarde.")
			RETURN
		END
	ELSE
		Info("Vous devez saisir une date valide de sauvegarde.")
		RETURN
	END
END
// Sauvegarde chaque mois
IF nTypeSauvegarde = schedMonthly THEN
	IF SAI_HoraireUnique <> "" THEN
		TriggerScheduledTask.Day = SEL_JourDuMois
		TriggerScheduledTask.Time = SAI_HoraireUnique
	ELSE
		Info("Vous devez saisir une heure valide de sauvegarde.")
		RETURN
	END
END
// Sauvegarde chaque semaine
IF nTypeSauvegarde = schedWeekly THEN
	IF SAI_HoraireUnique <> "" THEN
		TriggerScheduledTask.DayOfWeek = SEL_JourDeLaSemaine
		TriggerScheduledTask.Time = SAI_HoraireUnique
	ELSE
		Info("Vous devez saisir une heure valide de sauvegarde.")
		RETURN
	END
END
IF NOT SchedulerAddTask("MaTache") THEN 
	Error(ErrorInfo())
ELSE
	Info("L'application a été ajoutée au gestionnaire de tâches de Windows")
END
Versión mínima requerida
  • Versión 10
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local